<?php
	class LocationAction extends CommonAction { 
		public function index(){
			$id = intval( $_GET['id'] );
			if ( !isset( $_GET['provinces'] ) ){
            	$provinces = 0;
            }else{
            	$provinces = intval( $_GET['provinces'] );
            }
			if ( is_numeric( $id ) ){
				
				$model = D('Region');
                
                $where = array();
				
                switch( $_GET['type'] ){
					case 'Provinces' :
						$where['actid'] = 0;
						break;
					case 'City' :
						$where['actid'] = $id;
						break;
					case 'Region' :
						$where['actid'] = $id;
						break;
                }
				
				$list = $model->where( $where )->select();
				if ( empty( $list ) ){
					$list = $model->where("id='".$id."'")->select();
				}
                
                $this->assign("provinces",$provinces);
				$this->assign("list",$list);
				$this->display();
			}
	    }
	}
?>